home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12803 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  41 lines

  1. Newsgroups: comp.lang.c
  2. Path: howland.reston.ans.net!torn!nott!emr1!news
  3. From: Stephane Charette <charrick@netrover.com>
  4. Subject: Opening STDOUT As BINARY
  5. X-Nntp-Posting-Host: pc20.ccg.emr.ca
  6. Content-Type: text/plain; charset=us-ascii
  7. Message-ID: <3161CAD8.296C@netrover.com>
  8. Sender: news@emr1.emr.ca
  9. Content-Transfer-Encoding: 7bit
  10. Organization: Natural Resources Canada, Ottawa
  11. Mime-Version: 1.0
  12. Date: Wed, 3 Apr 1996 00:48:24 GMT
  13. X-Mailer: Mozilla 2.01 (Win16; I)
  14.  
  15. I've come across a problem, and I believe that it is
  16. caused by limitations in C/C++.  Can anyone help on the
  17. following:
  18.  
  19. I need to output binary information to the console, which
  20. is then redirected to a file by the o/s.  At the moment,
  21. I'm using printf( "%c", mychar ) to output the the binary
  22. data one character at a time as it comes in.
  23.  
  24. However, it seems that the character #7 (0x07, bell) gets
  25. sent to stdout followed by an automatic CR (0x0A).  Every
  26. other character in the ASCII table works fine!  Is there
  27. a way to reopen stdout in binary mode instead of as a text
  28. stream? The extra 0x0A characters are corrupting the data!
  29.  
  30. I've also tried "cout" and "putc", but they yield the same
  31. result.
  32.  
  33. Why do I need this:  this application runs as a CGI-BIN,
  34. and the web server EXPECTS the output to be sent to
  35. stdout.  I cannot fwrite() this information to a physical
  36. file since the web server is capturing the console output!
  37.  
  38. Thanks for any help,
  39.  
  40. Stephane Charette.
  41.